package xu.com.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import xu.com.service.Client;

@RestController
public class ConsumerController {

    @Autowired
    private RestTemplate restTemplate;

    @Autowired
    private Client client;

    @RequestMapping(value = "/echo1/{str}", method = RequestMethod.GET)
    public String echo1(@PathVariable String str) {
        return client.hello(str);
    }

    @RequestMapping(value = "/echo2/{str}", method = RequestMethod.GET)
    public String echo2(@PathVariable String str) {
        return restTemplate.getForObject("http://cloud-provider-1101/echo/" + str, String.class);
    }
}

